<?php

/**
 * @file
 * Theme settings .
 */

function solveto_theme_settings_footer(&$form, &$form_state) {
    global $base_url;
    $theme_path = drupal_get_path('theme',CURRENT_THEME);

    $form['solveto_settings']['footer'] = array(
        '#type' 					=> 'fieldset',
        '#weight' 				=> -4,
        '#prefix'  				=> '<div id="sf-footer">',
        '#suffix'        => '</div><!-- / #sf-design -->',
    );

    // 5. ---------------------------------- Footer --------------------------------------------
    $form['solveto_settings']['footer']['design_footer'] = array(
        '#type'             => 'fieldset',
        '#weight' 				=> -8,
        '#prefix' => '     <div class="widget">
                        <div class="title">
                            <img src="'.$base_url.'/'.$theme_path.'/img/theme-settings/images/icons/dark/preview.png" alt="" class="titleIcon">
                            <h6>Footer Settings</h6>
                        </div>
                        ',
        '#suffix'       => '</div>',
    );

    /*//////////////////////////////////////////// Social ///////////////////////////////////////////////////////
    $form['solveto_settings']['footer']['design_footer']['footer_social'] = array(
        '#type'                 => 'fieldset',
        '#prefix' => ' <div class="widget">
                        <div class="title">
                            <img src="'.$base_url.'/'.$theme_path.'/img/theme-settings/images/icons/dark/preview.png" alt="" class="titleIcon">
                            <h6>Social</h6>
                        </div>
                        ',
        '#suffix'       => '</div>',
    );
    $form['solveto_settings']['footer']['design_footer']['footer_social']['social_info'] = array(
        '#type' => 'container',
    );
    $js_data_default = '
    [{"name":"form_select","value":"fa|fa-facebook-square"},{"name":"form_input","value":"Address: No 2744, Los Angeles, USA"}]';
    $js_data = (theme_get_setting('social_array_hidden') != null) ? theme_get_setting('social_array_hidden') : $js_data_default;

    $array_social = json_decode($js_data,true);
    $array_social = array_chunk($array_social,2);

    $form['solveto_settings']['footer']['design_footer']['footer_social']['social_info']['addmore_button'] = array(
        '#markup' => '<a href="#" class="addmore-button wButton blueB ml15 m10"><span>Add More</span></a>',
    );
    $form['solveto_settings']['footer']['design_footer']['footer_social']['social_info']['wrap_sort_open'] = array(
        '#markup' => '<ul class="wrap-sort">',
    );
    foreach ($array_social as $key => $element) {
        $options_icon = get_option_icon();
        $options_icon_html = '';
        foreach ($options_icon as $group_key => $group_value) {
            foreach ($group_value as $option_key => $option_value) {
                $select = ($option_key == $element[0]['value']) ? 'selected="selected"' : '';
                $options_icon_html .= '<option value="'.$option_key.'" '.$select.'>'.$option_value.'</option>';
            }
        }
        $form['solveto_settings']['footer']['design_footer']['footer_social']['social_info']['sort_list'.$key] = array(
            '#markup' => '<li class="draggable-item sortable-item medium">
                            <!-- Button remove -->
                            <a href="#" class="remove-addmore-button">X</a>
                            <!-- Select Icon -->
                            <div class="form-elements input-select">
                                <div class="formRow">
                                    <label for="edit-form-select">Icon</label>
                                    <div class="formRight">
                                        <select data-selectdiv="icon-select-'.$key.'"  name="form_select" class="form-select form-select-icon icon-select-'.$key.'">
                                            '.$options_icon_html.'
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <!-- Input -->
                            <div class="form-elements input-element">
                                <div class="formRow">
                                    <label for="edit-form-input">Link </label>
                                    <div class="formRight">
                                        <input type="text" id="edit-form-input" name="form_input" value="'.$element[1]['value'].'" size="60" maxlength="128" class="form-text">
                                    </div>
                                </div>
                            </div>
                           </li>',
        );
    }
    $form['solveto_settings']['footer']['design_footer']['footer_social']['social_info']['wrap_sort_close'] = array(
        '#markup' => '</ul>',
    );
    $form['solveto_settings']['footer']['design_footer']['footer_social']['social_info']['social_array_hidden'] = array(
        '#type'          => 'hidden',
        '#default_value' => $js_data_default,
        '#attributes'    => array(
            'class' => array('addmore-input-hidden'),
        )
    );*/


    $form['solveto_settings']['footer']['design_footer']['footer_text'] = array(
        '#type' => 'textarea',
        '#resizable'    => false,
        '#default_value'    => theme_get_setting('footer_text',CURRENT_THEME),
        '#attributes'       => array(
            'class'         => array('textarea-border')
        ),
        '#prefix'   =>  '<div class="formRow"><label>Footer Text Display</label>',
        '#suffix'   => '</div>',
        '#field_prefix' => '<div class="formRight">',
        '#field_suffix' => '</div>',
    );

}

